<!--
 * @Author: 孙开源 && sunkaiyuan@namenode.cn
 * @Date: 2023-07-27 12:24:57
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-07-27 13:51:23
 * @Description: 
 * 
-->
<template>
  <el-dialog draggable overflow v-model="visible" :title="titleName" :width="400" destroy-on-close
    @closed="$emit('closed')">

    <sk-tabs type="border-card">
      <el-tab-pane ref="tab" label="基础信息">
        <el-form :model="form" :rules="rules" ref="dialogForm" label-width="70px" label-position="right">
          <el-row>
            <el-col :span="24">
              <el-form-item label="开票抬头" prop="name">
                <el-input v-model="form.name" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="统一税号" prop="tax_code">
                <el-input v-model="form.tax_code" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="开户行" prop="bank">
                <el-input v-model="form.bank" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="银行账号" prop="account">
                <el-input v-model="form.account" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="电话" prop="phone">
                <el-input v-model="form.phone" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-tab-pane>
    </sk-tabs>
    <template #footer>
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
    </template>
  </el-dialog>
</template>

<script>
export default {
  emits: ["success", "closed"],
  components: {},
  data() {
    return {

      dialog: { save: false },
      titleName: "",
      form: {},
      rules: {
        name: { required: true, message: "请填写开票抬头" },
      },
      visible: false,
      isSaveing: false,
    };
  },
  mounted() { },
  methods: {
    //显示
    open() {

      this.visible = true;
      return this;
    },
    //表单提交方法
    submit() {
      this.$refs.dialogForm.validate(async (valid) => {
        if (valid) {
          this.isSaveing = true;
          var res = await this.$API.basedata.businessCompany.billtradeAdd.post(this.form);
          this.isSaveing = false;
          if (res.code == 200) {
            this.$emit("success", res.data);
            this.visible = false;
            this.$message.success("操作成功");
          }
        }
      });
    },
    //表单注入数据
    setData(name, id) {
      this.titleName = "新增开票抬头【" + name + "】";
      this.form = {};
      this.form['company_id'] = id;
      return this;
    },
  },
};
</script>
 
